﻿using System;
using System.Linq;
using System.Web.Mvc;
using VOD.Models;

namespace VOD.Controllers
{
    public class NoticeController : Controller
    {
        readonly VODEntities _db = new VODEntities();
        // 最新公告
        // GET: /Notice/
        public ActionResult Index()
        {
            var notice = _db.Notices.AsEnumerable()
                .Last(n => n.InvalidDate==null || n.InvalidDate>DateTime.Now);
            return View(notice);
        }

        // 公告详情
        // GET: /Notice/Details/5
        public ActionResult Details(int id)
        {
            var notice = _db.Notices.Find(id);
            return View(notice);
        }

        // 公告列表
        // GET: /Notice/List/
        public ActionResult List()
        {
            var notices = _db.Notices.ToList();
            return View(notices);
        }

        protected override void Dispose(bool disposing)
        {
            _db.Dispose();
            base.Dispose(disposing);
        }
    }
}
